﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;

namespace Web2014112110
{
    public partial class SelectTeaInfo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = "教师查询个人成绩";
            string name;
            name = Session["name"].ToString();
            this.lblNowUser.Text =  name ;
            this.userName0.Text = name;
            String strCn = "Server=pc.hstc.cn;database=dhd2014112110;uid=2014112110;pwd=19941225";
            SqlConnection cn = new SqlConnection(strCn); //建对象
            try
            {
                cn.Open();
                string strSql = "SELECT   Image FROM  TeaInfo  WHERE   (Account = N'" + this.userName0.Text + "')";
                SqlCommand cmd = new SqlCommand(strSql, cn);
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    this.Image.ImageUrl = dr["Image"].ToString();
                }
            }
            catch
            {

            }
            finally
            {
                cn.Close();
            }
        }
        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (Session["Theme"] == null)
            {
                Page.Theme = "ThemeFour";
            }
            else if (Session["Theme"].ToString() == "themeFive")
            {
                Page.Theme = "themeFive";
            }
            else if (Session["Theme"].ToString() == "themeTwo")
            {
                Page.Theme = "ThemeTwo";
            }
            else if (Session["Theme"].ToString() == "themeThree")
            {
                Page.Theme = "themeThree";
            }
            else if (Session["Theme"].ToString() == "themeFour")
            {
                Page.Theme = "themeFour";
            }
        }
        protected void btnSelect_Click(object sender, EventArgs e)
        {
            string name;
            name = Session["name"].ToString();
            this.userName.Text = name;
            String strCn = "Server=pc.hstc.cn;database=dhd2014112110;uid=2014112110;pwd=19941225";
            SqlConnection cn = new SqlConnection(strCn); //建对象
            try
            {
                cn.Open();//打开连接
                //忽略检测范围
                string strNo = this.userName.Text;
                string strSql = "SELECT   Age,Gender, Place,Nation,email FROM  TeaInfo  WHERE   (Account = N'" + this.userName.Text + "')";
                //string strSql = "select * from Student";
                SqlCommand cmd = new SqlCommand(strSql, cn);
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    //this.txtCollegeName.Text = dr["CollegeName"].ToString();
                    this.txtAge.Text = dr["Age"].ToString();
                    this.txtGender.Text = dr["Gender"].ToString();
                    this.txtPlace.Text = dr["Place"].ToString();
                    this.txtNation.Text = dr["Nation"].ToString();
                    this.txtemail.Text = dr["email"].ToString();
                    this.lblInfo.Text = "教师查询成功！";
                }
                else
                {
                    this.lblInfo.Text = "教师查询失败！";
                }
                //this.GridView1.DataSource = dr;
                //this.GridView1.DataBind();
                //dr.Close();
            }
            catch (Exception ex)
            {
                this.lblInfo.Text = ex.Message;//将异常信息显示在label中
            }
            finally
            {
                cn.Close();
            }
        }
    }
}